<?php
require_once(dirname(__FILE__) . '/app.php');
need_login();

require_once(dirname(__FILE__) . '/wxpay/jssdk.php');

$jssdk = new JSSDK($INI['system']['appid'], $INI['system']['appscert']);
$signPackage = $jssdk->GetSignPackage();


$id = htmlspecialchars($_GET['id']);
$isget = isset($_GET['isget'])? intval($_GET['isget']) : 0;

$card = DB::LimitQuery('card', array(
		'condition' => array(
		'id' =>$id,
		),
	'one' => true,
));

if(!$card)
{
	redirect( WEB_ROOT . "/index.php");
	die();
}

$daytimenow_ev56_s = time();
/*判断预告，过期，秒杀，热销*/
$condition_ev56_s = array(
	'team_type' => 'normal',
	'max_number >0',
	"begin_time <= $daytimenow_ev56_s ",
	"end_time > $daytimenow_ev56_s",
);

$city_id = abs(intval($city['id']));

$condition_ev56_s[] = "((city_ids like '%@$city_id@%' or city_ids like '%@0@%') or city_id in(0,$city_id))";
$order='ORDER BY now_number DESC, id DESC';

$teams_ev56_sql = DB::LimitQuery('team', array(
	'condition' => $condition_ev56_s,
	'order' => $order,
	'size' => 1,
	'one' => true,
	
));
$team = $teams_ev56_sql;
	
$is_get = false;

if($card['uid'] == 1 && $card['consume'] == 'N' && $card['begin_time']<= time() && $card['end_time'] >time())
{
	$is_get = true;
} 



if($isget == 1)
{
	if($is_get)
	{
		include template('bonus_view_get');
	}else {
		include template('bonus_view');
	}
	
} else {
	if($is_get)
	{
		include template('bonus_view_share');
	}
	else 
		include template('bonus_view');
}

